package com.xr.hr.sys;

import com.bstek.dorado.common.*;
import com.bstek.dorado.data.*;
import com.bstek.dorado.data.db.DBStatement;
import com.bstek.dorado.view.*;
import com.bstek.dorado.view.data.*;
import com.bstek.dorado.view.control.*;
import com.xr.common.CommUtil;

/**
 * menuGuideViewModel
 */
public class menuGuideViewModel extends DefaultViewModel {
  protected void doUpdateData(ParameterSet parameters, ParameterSet outParameters)
      throws Exception {
    // Add your code here
    super.doUpdateData(parameters, outParameters);
  }
  
  public void showMenu(ParameterSet parameters, ParameterSet outParameters)
  throws Exception {
	  DBStatement dbs = new DBStatement();
	  Dataset ds=getDataset("datasetUser");
	  dbs.setSql("update rt_user set IF_SHOW_MENU=" + ds.getString("IF_SHOW_MENU")+" where user_id=" + CommUtil.getUserId() );
	  dbs.execute();
	  dbs.close();
 
 }
  public void favouriteRemove(ParameterSet parameters, ParameterSet outParameters)
  throws Exception {
	  DBStatement dbs = new DBStatement();
	  Dataset ds=getDataset("datasetFavourite");
	  dbs.setSql("update rt_function_right set if_favourite=0 where user_id="+CommUtil.getUserId()+" and function_id="+ds.getString("function_id"));
	  dbs.execute();
	  dbs.close();
 
 }
  public void addRemoveTree(ParameterSet parameters, ParameterSet outParameters)
  throws Exception {
	  DBStatement dbs = new DBStatement();
	  Dataset ds=getDataset("functionDataset");
	  dbs.setSql("update rt_function_right set if_favourite=decode(if_favourite,0,1,0) where user_id="+CommUtil.getUserId()+" and function_id="+ds.getString("function_id"));
	  dbs.execute();
	  dbs.close();
 }
  public void addRemoveTable(ParameterSet parameters, ParameterSet outParameters)
  throws Exception {
	  DBStatement dbs = new DBStatement();
	  Dataset ds=getDataset("datasetFuncionTable");
	  dbs.setSql("update rt_function_right set if_favourite=decode(if_favourite,0,1,0) where user_id="+CommUtil.getUserId()+" and function_id="+ds.getString("function_id"));
	  dbs.execute();
	  dbs.close();
 }
}
